<template>
  <div class="pagination">
    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[5, 10, 15, 20]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script lang="ts" setup>
import { ref, defineProps, defineEmits } from 'vue'
const props = defineProps({
  total: Number
})
const emit = defineEmits(['changePage', 'changeRows'])
const currentPage = ref(1)
const pageSize = ref(10)
const small = ref(true)
const background = ref(true)
const disabled = ref(false)

const handleSizeChange = (val: number) => {
  // console.log(`${val} items per page`)
  emit("changeRows", val)
}
const handleCurrentChange = (val: number) => {
  // console.log(`current page: ${val}`)
  emit("changePage", val)
}
</script>

<style lang="scss" scoped>
.pagination::v-deep{
  margin-top: 12px;
  background-color: #fff;
  padding: 7px 5px;
}
</style>